<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<div class="form-horizontal" role="form" >
	<input type="hidden" id="token" name="token" value="<%=request.getAttribute("token") %>" />
    <input id="id" value="${goodsCat.id}"  type="hidden"/>
		<div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">名称:</label>
	        <div class="col-md-9">
	        	 <input id="name" value="${goodsCat.name}" data-check="require:true;code:^[a-zA-Z0-9\u4e00-\u9fa5]{1,30};message:不能为空" type="text" placeholder="名称" class="form-control" name="name"/>
	        </div>
	    </div>
    	<div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">图片:</label>
	        <div class="col-md-9">
	        	 <div class="col-md-10">
		        	 <input class="fileInput" id="imageUploadify" type="file" name="file" accept="image/*"/>
		        	 <div class="imageUploadify">   
						<c:if test="${not empty(goodsCat.image)}">
						<c:forEach items="${fn:split(goodsCat.image,',')}" var="i">
							<img src="${i}" style="width: 60px;height: 60px">
						</c:forEach>
						</c:if>
					 </div>
		        </div>
	        </div>
	    </div>
		<div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">排序:</label>
	        <div class="col-md-9">
	        	 <input id="sort" value="${goodsCat.sort}"  type="text" placeholder="排序" class="form-control" name="sort"/>
	        </div>
	    </div>
	    <div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">规格:</label>
	        <div class="col-md-9" id="specsDiv">
	        	<c:forEach items="${specs }" var="s">
	        	<label class="checkbox-inline i-checks"><input type="checkbox" value="${s.id }">${s.name }</label>
	        	</c:forEach>
	        </div>
	    </div>
</div>
<script>
$(function(){
	jQuery.checkall(false);
})

$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green"});
$(".imageUploadify img").each(function(){
	images.push($(this).attr("src"));
})
$("#imageUploadify").uploadify({
	'buttonImage':'${ctx}/static/js/plugins/uploadify/uploadify-button.png',
    'swf': '${ctx}/static/js/plugins/uploadify/uploadify.swf',
    'uploader':'${ctx}/file/uploadOss',
    "multi":false,
    'onFallback' : function() {//检测FLASH失败调用 
    	alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");  
    },  
    'onUploadSuccess':function(file, data, response){
    	var jData = jQuery.parseJSON(data);
        $(".imageUploadify").html("<img src=\""+jData.data+"\" style=\"width: 60px;height: 60px;padding-left:5px;\">");
	}
});
</script>